package ch.trackedbean.data.converter;

import ch.trackedbean.copier.*;

/**
 * Converter for String to Int conversion.
 * 
 * @author M. Hautle
 */
public class StringToInt implements IPropertyConverter<String, Integer> {
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String convertDst2Src(Integer dst, Class<? extends String> src, IMappingContext ctx) {
		return dst != null ? dst.toString() : null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Integer convertSrc2Dst(String src, Class<? extends Integer> dst, IMappingContext ctx) {
		return src != null ? Integer.valueOf(src) : new Integer(0);
	}
}
